package com.ruoyi.web.util;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;

public class ChatUtil {

    private static final ChatLanguageModel model;

    static {
        model = OpenAiChatModel.builder()
                .baseUrl("https://api.deepseek.com")
                .apiKey("sk-5df265805e3d4e83a96569277474e1d2")
                .modelName("deepseek-chat")
                .build();
    }

    /**
     * 获取AIService代理对象
     * @param serviceClass 要创建的AI服务接口类
     * @return AI服务实例
     * @param <T> 服务接口类型
     */
    public static <T> T getService(Class<T> serviceClass) {
        return AiServices.builder(serviceClass)
                .chatLanguageModel(model)
                .build();
    }
}